package com.ytjj.qmyx.admin.service.impl;

import com.ytjj.qmyx.admin.dao.SelectCommentDao;
import com.ytjj.qmyx.admin.dao.SelectRelationDao;
import com.ytjj.qmyx.admin.model.response.SelectCommentResponse;
import com.ytjj.qmyx.admin.service.MemberService;
import com.ytjj.qmyx.admin.service.SelectCommentService;
import com.ytjj.qmyx.mall.model.SelectComment;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 *
 * @Version: 1.0
 */
@Service
public class SelectCommentServiceImpl implements SelectCommentService {

	@Resource
	private SelectCommentDao selectCommentDao;

	@Resource
	private MemberService memberService;

	@Resource
	private SelectRelationDao selectRelationDao;

	@Override
	public List<SelectCommentResponse> selectList(Integer selectExamId) {
		if (memberService.getAdmin().getId() != 32) {
			selectRelationDao.updateStatus(selectExamId, 2, 1);
		} else {
			selectRelationDao.updateStatus(selectExamId, 1, 1);
		}
		return selectCommentDao.selectList(selectExamId);
	}

	@Override
	public Integer insertComment(Integer selectExamId, String content) {
		if (memberService.getAdmin().getId() != 32) {
			selectRelationDao.updateStatus(selectExamId, 1, 0);
		} else {
			selectRelationDao.updateStatus(selectExamId, 2, 0);
		}
		return selectCommentDao.insertComment(selectExamId, memberService.getAdmin().getId(), content);
	}
}
